//
//  AboutSetViewController.swift
//  MyTest
//
//  Created by guanzhongwang on 2021/5/7.
//

import UIKit

class AboutSetViewController:CommonViewController {
    
    private let tableView = UITableView.init(frame: CGRect.zero, style: .grouped)
    private var dataList:Array<Array<SetItemModel>> = []
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.
        self.title = "关于头条"
        tableView.separatorColor = Separator_COLOR
        tableView.backgroundColor = BACKGROUND_COLOR
        self.view.addSubview(tableView)
        tableView.snp.makeConstraints({
            $0.edges.equalToSuperview()
        })
        tableView.delegate = self
        tableView.dataSource = self
        tableView.register(SetItemArrowCell.self, forCellReuseIdentifier: "SettingArrowCell")
        tableView.estimatedSectionHeaderHeight = 0
        tableView.estimatedSectionFooterHeight = 0
        tableView.rowHeight = 44.0
        
        dataList.append([SetItemModel.init(type: .Arrow, title: "当前版本",tip: "1.1.0",hiddenArrow:true),
                         SetItemModel.init(type: .Arrow, title: "用户协议"),
                         SetItemModel.init(type: .Arrow, title: "社区规范"),
                         SetItemModel.init(type: .Arrow, title: "相关许可证")])

    }

}
extension AboutSetViewController:UITableViewDelegate{
    func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
        return 10.0
    }
    func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
        return 0.001
    }
   
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        SystemLog("didSelectRowAt")
        tableView.deselectRow(at: indexPath, animated: false)
    }
    
}
extension AboutSetViewController:UITableViewDataSource{
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        
        return dataList[section].count
    }
    func numberOfSections(in tableView: UITableView) -> Int {
        return dataList.count
    }
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let item = dataList[indexPath.section][indexPath.row]
        let cell = tableView.dequeueReusableCell(withIdentifier: "SettingArrowCell", for: indexPath) as? SetItemArrowCell
        cell?.binding(item)
        cell?.selectionStyle = .none
        return cell!
    }
    
    @objc func linkclick() {
        SystemLog("linkclick")
    }
}


